package com.iis.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Properties;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;

import org.jdatepicker.impl.JDatePanelImpl;
import org.jdatepicker.impl.JDatePickerImpl;
import org.jdatepicker.impl.UtilDateModel;

import com.iis.entity.Admin;
import com.iis.entity.Agent;
import com.iis.entity.Client;
import com.iis.entity.Salesman;

public class AddTransactionForm extends JFrame {
	
	private static AddTransactionForm frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JTable dataTable = new JTable();
					frame = new AddTransactionForm(dataTable,null,null,null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public AddTransactionForm(JTable dataTable, Client client, Agent agent, Salesman staff) {
		this.setTitle("Add New Insurance Transaction");
		InitializeForm(client,agent,staff);
	}
	
	public void InitializeForm(Client client, Agent agent, Salesman staff){
		JPanel contentPane = new JPanel();
		contentPane.setLayout(null);
		contentPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
		
		JLabel lblSales;
		if(agent != null)
			lblSales = new JLabel("Agent ID");
		else lblSales = new JLabel("Employee No");
		lblSales.setFont(lblSales.getFont().deriveFont(12.0f));
		lblSales.setBounds(40, 40, 100, 30);
		
		JLabel lblClient = new JLabel("Client Name");
		lblClient.setFont(lblSales.getFont());
		lblClient.setBounds(40, 80, 100, 30);
		
		JLabel lblCategory = new JLabel("Insurance Type");
		lblCategory.setFont(lblSales.getFont());
		lblCategory.setBounds(40, 120, 100, 30);
		
		JLabel lblSalesID = new JLabel();
		if(agent != null)
			lblSalesID.setText(agent.getAgentNo());
		else if(staff != null) lblSalesID.setText(staff.getEmployeeNo());
		lblSalesID.setFont(lblSales.getFont());
		lblSalesID.setBounds(190, 40, 220, 30);
		
		String[] nameStrings = { "Martinus Sigit", "Yustinus Widya" };
		JComboBox nameList = new JComboBox(nameStrings);
		nameList.setSelectedIndex(0);
		nameList.setFont(lblSales.getFont());
		nameList.setBounds(190, 80, 220, 30);
		
		String[] typeStrings = { "Total Loss", "Comprehensive" };
		JComboBox typeList = new JComboBox(typeStrings);
		typeList.setSelectedIndex(0);
		typeList.setFont(lblSales.getFont());
		typeList.setBounds(190, 120, 220, 30);
		
		contentPane.add(lblSales);
		contentPane.add(lblSalesID);
		
		contentPane.add(lblClient);
		contentPane.add(nameList);
		
		contentPane.add(lblCategory);
		contentPane.add(typeList);
		
		JButton btnSubmit = new JButton("Submit");
		btnSubmit.setBounds(190, 160, 100, 40);
		contentPane.add(btnSubmit);
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.setBounds(310, 160, 100, 40);
		contentPane.add(btnCancel);
		
		setContentPane(contentPane);
		
		getContentPane().setLayout(null);
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setBounds(100, 100, 500, 280);
		
		frame = this;
		
		btnSubmit.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				
			}
		});
		
		btnCancel.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				frame.setVisible(false);
			}
		});
	}
}